<?php if (count($this->paginator) == 0): ?>
		<div class="deal">
			<div class="deal_content_top"></div>
			<div class="deal_content">
				Không có deal nào
			</div>
		</div>
<?php else: ?>
	<?php foreach ($this->paginator as $deal): ?>	
		<div class="deal">
			<div class="deal_content_top"></div>
			<div class="deal_content">
				<h3><a href="<?php echo $this->baseUrl('index.php/cms/index/deal/id/') . $deal->deal_id ?>"><?php echo $deal->deal_title ?></a></h3>
				<div class="deal-left">				
				<?php if($deal->deadline > date('Y-m-d g:i:s')): ?>
					<div class="price"><?php echo number_format($deal->price, 0, ".", ",") . 'đ' ?></div>
					<form action="<?php echo $this->baseUrl('index.php/checkout/cart/add/id/'.$deal->deal_id) ?>" method="POST">
						<input type="submit" class="buttonPrice" value=""/>
					</form>
				<?php else: ?>
					<div class="price"><?php echo number_format($deal->price, 0, ".", ",") . 'đ' ?></div>
					<input type="button" class="buttonPrice2" value="" onclick="alert('Đã hết hạn mua')"/>
				<?php endif; ?>
					<div class="deal-block2"><span class="strongText">Giá gốc :&nbsp;</span><span class="strongPrice"><?php echo number_format($deal->value, 0, '.', ',') . 'đ' ?></span></div>
					<div class="deal-block2"><span class="strongText">Tiết kiệm :&nbsp;</span><span class="strongPrice"><?php echo number_format((floatval($deal->value) - floatval($deal->product_price)), 0, ',', '.') . 'đ' ?></span></div>
					<div class="deal-block2">
						<span class="strongText">Ngày hết hạn</span><div class="time"><?php echo date('d/m/Y', strtotime($deal->deadline)) ?></div>
					</div>
					<div class="deal-block2">
						<?php if($this->reports[$deal->deal_id]->deal_left <= 0): ?>
                                                Có <?php echo $this->reports[$deal->deal_id]->count_deal ?> người mua
                                                <br />Đã đạt được Giá tốt!
                                                <?php else: ?>
                                                Còn <?php echo $this->reports[$deal->deal_id]->deal_left ?> phiếu để
                                                <br />Đạt được giá tốt!
                                                <?php endif ?>
                                                <?php if($this->reports[$deal->deal_id]->count > 0): ?>
						<h4 style="margin:5px 0;">Danh sách người mua</h4>
						<ul style="padding-left:3px;margin:0;" id="deal_<?php echo $deal->deal_id?>">
                                                    <?php foreach($this->reports[$deal->deal_id]->users as $user): ?>
							<li><img src="<?php echo $this->baseUrl('public/images/user.png')?>" style="margin: 0 5px;" alt=""/><?php echo $user->fullname ?></li>
                                                    <?php endforeach ?>
						</ul>
                                                <a href="#" onclick="loadUser(<?php echo $deal->deal_id ?>);return false;">Xem thêm >></a>
                                                <?php endif ?>
					</div>
				</div>
				<div class="deal-right">
					<div class="deal-image">
						<div class="saleOff">
							<span class="price off">
								<?php
								$percent = (1 - ($deal->product_price / $deal->value))*100;
								echo number_format($percent, 0, ".", ","). '%';
								?>
							</span>
						</div>
						<img src="<?php echo $this->baseUrl('public/upload/images/deals/' . $deal->deal_avatar)?>" class="deal-right-img" alt="HopMua.com" />
						<div class="deal-right-comment"><a href="<?php echo $this->baseUrl('index.php/cms/index/deal/id/') . $deal->deal_id ?>">Xem chi tiết</a></div>
					</div>					
					<div class="deal-right-content"><?php echo $deal->deal_intro ?></div>
					<div class="deal-right-company" style="overflow:hidden;padding: 10px 0px;clear:both;">					
						<span>
							<a href="<?php echo $deal->supplier_url ?>" style="text-decoration:none;font-weight:bold;color:#235b96;"><?php echo $deal->supplier_name ?></a> - <?php echo $deal->supplier_contact ?> 
						</span>
					</div>
					
					<?php
					$link = (@$_SERVER["HTTPS"] == "on") ? "https://" : "http://";
					$link .= $_SERVER["SERVER_NAME"] . $this->baseUrl('index.php/cms/index/deal/id/'.$deal->deal_id);
					?>
					
					<iframe src="http://www.facebook.com/plugins/like.php?href=<?php echo $link ?>&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;font&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>
							
				</div>
			</div>
			<div class="deal_content_bottom"></div>
		</div>
	<?php endforeach ?>
	<div align="center"><?php echo $this->paginator; ?></div>
<?php endif ?>	